package com.itheima.config.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @作者 itcast
 * @创建日期 2020/11/10 15:19
 **/
@WebFilter("/actuator/bus-refresh")
public class BusRefreshFilter extends GenericFilter {
    /**
     * 过滤方法
     * @param servletRequest
     * @param servletResponse
     * @param filterChain
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        // git所携带的参数  是在request请求的body中
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(request.getInputStream()));
        bufferedReader.lines().forEach(System.out::println);
        filterChain.doFilter(request,servletResponse);
    }
}
